//设备添加
import Axios from "./../utils/axios";
import api from "./../api/index";

//数据渲染 发起Axios请求
function getfacilityList(limit,page,name) {
  //api.apiFacility.facilityPage这里返回的是路由
  console.log(limit,page,name);
  //用Axios的post方法向api.apiFacility.facilityPage地址发起请求
  return Axios.post(api.apiFacility.facilityPage,{
    limit,page,name
  });
}

//添加 发起Axios请求
function facilityAdd(addForm) {
  //apiFacility文件里面的facilityAdd方法 Swagger调试里面该接口的请求方式是什么，这里的Axios请求就是什么方式
  return Axios.post(api.apiFacility.facilityAdd, addForm);
}

//删除 发起Axios请求
function facilityDelete(id) {
  console.log("serive中删除的id-"+id);
  return Axios.delete(api.apiFacility.facilityDelete+"?id="+id,{
    headers:{
      "Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"
    }
  }
  );
}

//数据存放地点
function storageSite(){
  return Axios.get(api.apiFacility.storageSite);
}

//修改
function facilityUpdate(modifyForm){
return Axios.post(api.apiFacility.facilityUpdate,modifyForm);
}

export default {
  facilityAdd,
  getfacilityList,
  facilityDelete,
  facilityUpdate,
  storageSite,
};
